package com.demo;

import com.exception.InsufficientFundException;
import com.exception.NotNegativeNumber;

public class ATM {
	
	private double banlance;
	private double num;
	private String ID;
	
	public ATM(String id) {
		this.ID=id;
	}
	
	//存款方法
	public void deposit(double banlance) throws NotNegativeNumber{
		if(banlance < 0){
			throw new NotNegativeNumber();
		}
		
		if(this.banlance!=0){
			banlance=this.banlance + banlance;
		}else{
			this.banlance=banlance;
		}
	}
	
	//取款方法
	public void withDraw(double Money) throws InsufficientFundException,
							      NotNegativeNumber{
		if(Money>banlance){
			throw new InsufficientFundException();
		}else{
			this.banlance=banlance-Money;
		}
	}
	
	//显示余额
	public void showBalance(){
		System.out.println("您的余额为："+banlance);
	}
	
	public void show(){
		System.out.println(ID + "用户您好，欢迎使用ATM");
		System.out.println("选择1，存款业务");
		System.out.println("选择2，取款业务");
		System.out.println("选择3，查询余额业务");
		System.out.println("选择4，退出");
	}
	
}
